
public class Bus {
	
	Node nStart;
	Node nStop;
	int latency;
	int bw_mult;
	int link_weight;
	
	int noVcs=10; //number of virtual channels on this connection
	int lastVc=0; //last used VC; for round robin implementation;
	
	Buffer vc[];
	
	
	private Bus(Node n1, Node n2, int latency, int bw_mult, int link_weight){
		nStart=n1;
		nStop=n2;
		this.latency=latency;
		this.bw_mult=bw_mult;
		this.link_weight=link_weight;
		//System.out.println("Am creat o noua conexiune");
		
	}
	
	public static Bus create(Node n1, Node n2,int latency, int bw_mult, int link_weight){
		return new Bus(n1, n2,latency, bw_mult, link_weight);
	}
	
	public void setVirtualChannels(int vcs){
		noVcs=vcs;
		vc= new Buffer[vcs];
	}
	
	public String toString(){
		return nStart+"->"+nStop;
	}
	
	public void receivePackage(Package p){
		//we allready know the source and dest;
		//all we have to do is select the best VC
		//for now we use the round robin manner
		
		//lastVc=(lastVc+1)%noVcs; //this is the new VC
		System.out.println("Sunt busul "+this+" si am primit pachetul "+p);
		
		try {
			//vc[lastVc].add(p);
			vc[0].add(p);
			System.out.println("Got package "+p);
		} catch (BufferOverflowException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
	

}
